<template>
  <header>
    <div class="l-content">
      <el-button plain icon="el-icon-menu" size="mini" @click="handleMenu"></el-button>
      <h3 style="color: #fff; text-align: center">首页</h3>
    </div>
    <div class="r-content">
      <el-dropdown trigger="click" szie="mini" >
        <img :src="userImg" width="40px" height="40px" />
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item @click.native="logOut">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
export default {
  name: "CommentHeader",
  data() {
    return {
      userImg: require("../assets/logo.png"),
    };
  },
  methods:{
    handleMenu(){
      this.$store.commit('collapseMenu')
    },
    logOut(){
      this.$store.commit('clearToken');
      this.$store.commit('clearMenu');
      this.$router.push('/login')
    }
  }
};
</script>

<style scoped>
    header{
        display: flex;
        width: 100%;
        height: 100%;
        justify-content: space-between;
        align-items: center;
    }
    .l-content{
        display: flex;
        align-items: center;
        
    }
    .el-button{
            margin-right: 20px;
        }
</style>